#include <stdio.h>
#include <string.h>

#define TRUE  1
#define FALSE 0

//function prototype testPalindrome
const char* testPalindrome(char *str);

//function main
int main(int argc, char **argv){
  //define local variable str as a pointer to character
  char *str;
  //define local variable msg as a pointer to character
  const char *msg; 

  //print "Enter string: " 
  printf("Enter string: ");
  //read string
  scanf("%s", str);

  //test if string is a palindrome and return a message
  msg = testPalindrome(str);

  //print return message 
  printf("%s", msg);

  return 0;
}

//function testPalindrome
const char* testPalindrome(char *str){
  //define local variables 
  int n, m, i, found;

  // variabile n the length of the string
  n = strlen(str);
  // the length of string to check if palindrome
  m = n/2;
  
  // check if first character is the same as the same as last character; second, like second last and so on
  found = FALSE;
  i = 0;
  while(i<=m && !found){
    // check if characters at position i and n-i does not respect the rule of the palindrome
    if(str[i] != str[n-i-1]){
      // character at position i and n-i does not respect the rule of palindrome
      found = TRUE;
    }
    i++;
  }

  // return a message
  if(!found){
    return "This string is a palindrome\n";
  }
  else{
    return "This string is not a palindrome\n";
  }
  
}


